<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
          <p class="login-tip">输入管理员用户名和密码即可</p>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ userName, password }) {
      var that=this;
      this.handleLogin({ userName, password }).then(res => {
        this.getUserInfo().then(res => {
          console.log(userName);
          


 this.$axios
        .post("dealLogin", {
          loginname: userName,
          password: password
        })
        .then(response => {
          var status = response.data.code;
          
          if (status == 0) {
           this.$Notice.success({
              title: "登陆成功"
            });
           that.$router.push({
            name: that.$config.homeName
          })
          }else{
            this.$Notice.error({
               title: "用户名或密码错误"
            });
            
          }
        })
        .catch(response => {});




          
        })
      })
    }
  }
}
</script>

<style>

</style>
